<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8"> 
	<title>Document</title>
	<script type="text/javascript" src="deferred.js"></script>
	<script type="text/javascript" src="promise.js"></script>
	<script>
		//var promise = new Promise();
		//console.log(promise.promise().state());
		/*var a = 1;
		var d = function(dfd){
			setTimeout(function(){
				dfd.resolve("aaaa");
				a=2;
			},3000);
			return dfd.promise().promise();
		},
		 d1 = function(dfd){
			setTimeout(function(){
				dfd.resolve("bb");
				
			},3000);
			return dfd.promise().promise();
		},
		 d2 = function(dfd){
			setTimeout(function(){
				dfd.resolve("ccc");

			},3000);
			return dfd.promise().promise();
		};

		Deferred.any(Deferred(d),Deferred(d1),Deferred(d2)).then(function(){
			console.log(arguments);
		},function(){
			console.log("fail");
		})*/

		/*var d = new Deferred();
		d.then(function(){
			console.log("1");
		}).then(function(){
			console.log("2");
			d.reject();
		}).then(function(){
			console.log("3");

		},function(){
			console.log("reject");

		}).then(function(){
			
			console.log("4");
			
		});
		i =0;
		setTimeout(function(){
			d.resolve();
		},1000)*/
	var d = Promise();
	d.then(function(){
		console.log("1");
		console.log(arguments);
		return "1"
	}).then(function(){
		console.log("2");
		console.log(arguments);
		return "2"
	}).then(function(){
		console.log("3");
		console.log(arguments);
	});
	setTimeout(function(){
		d.resolve("0");
		console.log(d.promise().promise());
	}, 1000);


	
	</script>
</head>
<body>
	
</body>
</html>